<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="ElasticSearch, 鸟鸟">
    <meta name="description" content="大家好，我是鸟鸟，今年20岁，喜欢打篮球，搭建的这个博客是用来记录平时的一些学习笔记和心得">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>ElasticSearch | 鸟鸟</title>
    <link rel="icon" type="image/png" href="/yueyueniao-gif/favicon.png">

    <link rel="stylesheet" type="text/css" href="/yueyueniao-gif/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/yueyueniao-gif/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/yueyueniao-gif/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/yueyueniao-gif/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/yueyueniao-gif/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/yueyueniao-gif/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/yueyueniao-gif/css/my.css">

    <script src="/yueyueniao-gif/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 5.0.2"><link rel="alternate" href="/yueyueniao-gif/atom.xml" title="鸟鸟" type="application/atom+xml">
<link rel="stylesheet" href="/yueyueniao-gif/css/prism-tomorrow.css" type="text/css"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/yueyueniao-gif/" class="waves-effect waves-light">
                    
                    <img src="/yueyueniao-gif/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">鸟鸟</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/yueyueniao-gif/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/yueyueniao-gif/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/yueyueniao-gif/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/yueyueniao-gif/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/yueyueniao-gif/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/yueyueniao-gif/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/yueyueniao-gif/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/yueyueniao-gif/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">鸟鸟</div>
        <div class="logo-desc">
            
            大家好，我是鸟鸟，今年20岁，喜欢打篮球，搭建的这个博客是用来记录平时的一些学习笔记和心得
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/yueyueniao-gif/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/yueyueniao-gif/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/yueyueniao-gif/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/yueyueniao-gif/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/yueyueniao-gif/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/yueyueniao-gif/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/yueyueniao-gif/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/yueyueniao-gif/medias/featureimages/3.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">ElasticSearch</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/yueyueniao-gif/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    .toc-fixed .toc-link::before{
        position: fixed!important;/*当toc的位置改为fixed时，.toc-link::before也要改为fixed*/
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/yueyueniao-gif/tags/ElasticSearch/">
                                <span class="chip bg-color">ElasticSearch</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/yueyueniao-gif/categories/ElasticSearch/" class="post-category">
                                ElasticSearch
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-12-16
                </div>
                

                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    4.5k
                </div>
                

                

                
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="ElasticSearch"><a href="#ElasticSearch" class="headerlink" title="ElasticSearch"></a>ElasticSearch</h1><h2 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h2><ul>
<li>Elaticsearch，简称为es，es是一个开源的<strong>高扩展</strong>的<strong>分布式全文检索引擎</strong>，</li>
<li>它可以近乎<strong>实时的存储、检索数据；</strong>本身扩展性很好，可以扩展到上百台服务器，处理PB级别（大数据时代）的数据。</li>
<li>es也是使用Java开发并使用Lucene作为其核心来实现所有索引和搜索的功能，但是它的目的是通过简单的RESTful API来隐藏Luncene的复杂性，从而让全文搜索变得简单。</li>
</ul>
<h2 id="ES安装及head插件安装"><a href="#ES安装及head插件安装" class="headerlink" title="ES安装及head插件安装"></a>ES安装及head插件安装</h2><h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><p><strong>直接解压就可以了</strong></p>
<p><img src="https://s3.jpg.cm/2020/12/17/kI0yz.png" alt="kI0yz.png"></p>
<p><strong>目录结构</strong></p>
<pre><code>bin       启动文件
config    配置文件
    log4j2               日志配置文件
    jvm.options jav      a虚拟机相关配置
    elasticsearch.yml    ealsticsearch的配置文件！默认9200端口！跨域！
lib       相关jar包
logs      日志！
modules   功能模块
plugins   插件！</code></pre>
<p><strong>启动</strong></p>
<ol>
<li><p>打开bin目录</p>
</li>
<li><p>双击elasticsearch.bat文件</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kI37u.png"></p>
</li>
<li><p>访问9200</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kID9Q.png" alt="kID9Q.png"></p>
</li>
</ol>
<h3 id="安装可视化界面-head插件"><a href="#安装可视化界面-head插件" class="headerlink" title="安装可视化界面 head插件"></a>安装可视化界面 head插件</h3><p>   <strong>也是直接解压就可以了</strong></p>
<ol>
<li><p>下载插件，在elasticsearch-head-master目录下执行cnpm install</p>
</li>
<li><p>解决跨域问题，在elasticsearch.yml文件中配置如下</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kL5kO.png" alt="kL5kO.png"></p>
</li>
<li><p>启动 npm install</p>
</li>
</ol>
<h3 id="安装Kibana"><a href="#安装Kibana" class="headerlink" title="安装Kibana"></a>安装Kibana</h3><ol>
<li><p>解压即用</p>
</li>
<li><p>解压后的目录</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kLABr.png" alt="kLABr.png"></p>
</li>
<li><p>启动，双击bin目录下的kibana.bat文件 ，访问测试</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kLify.png" alt="kLify.png"></p>
</li>
<li><p>汉化i18n.locale: “zh-CN”</p>
<pre><code>修改elasticsearch\kibana-7.6.1-windows-x86_64\config目录下的kibana.yml如下：

i18n.locale: "zh-CN"</code></pre>
</li>
</ol>
<h2 id="ES核心概念"><a href="#ES核心概念" class="headerlink" title="ES核心概念"></a>ES核心概念</h2><p><strong>elasticsearch（集群）中可以包含多个索引（数据库），每个索引中可以包含多个类型（表），每个类型下又包含多个文档（行），每个文档中又包含多个字段（列）</strong></p>
<table>
<thead>
<tr>
<th>Relational DB</th>
<th>Elasticsearch</th>
</tr>
</thead>
<tbody><tr>
<td>数据库（database）</td>
<td>索引（indices）</td>
</tr>
<tr>
<td>表（tables）</td>
<td>types（慢慢会被弃用）</td>
</tr>
<tr>
<td>行（rows）</td>
<td>documents</td>
</tr>
<tr>
<td>子弹（columns）</td>
<td>fields</td>
</tr>
</tbody></table>
<p><strong>物理设计：</strong></p>
<p>elasticsearch在后台把每个<strong>索引划分成多个分片</strong>，每分分片可以在集群中的不同服务器间迁移</p>
<p><strong>逻辑设计：</strong></p>
<p>一个索引类型中，包含多个文档，比如说文档1，文档2.当我们索引一篇文档时，可以通过这样的一个顺序找到它：索引&gt;类型&gt;文档ID，通过这个组合我们就能所引导某个值的文档。注意：ID不必是整数，实际上他是个字符串。</p>
<h3 id="索引（index）"><a href="#索引（index）" class="headerlink" title="索引（index）"></a>索引（index）</h3><p>在elasticsearch中，索引有两种含义：</p>
<ul>
<li>一种是名词意义上的索引。我们通常所说的索引也大多指这一种，这时候的索引就是文档(Document)的容器，是具有某种相似特性文档的集合，所以，在设计elasticsearch时，通常将相似的文档存放在同一个索引中（当然，个别document可能多一个或少一个field），这样Elasticsearch对磁盘存储的利用率最高。例如，对于博客类系统，可以将文章（artical）存放为一个索引中，将作者（author）存放为一个索引。索引由一个名称（必须全部是小写，不能以’_’, ‘-‘, 或 ‘+’开头）标识，当对其中的文档执行索引、搜索、更新和删除操作时，该名称用于引用索引。通常索引是由两部分构成：Mapping和Setting。Mapping 定义该索引包含的文档的数据结构的信息；Setting定义了该索引的数据分布信息。</li>
<li>另一种索引是指动词意义上的索引。保存一个文档到索引(名词)的过程，就类似于SQL语句中的 INSERT关键词，当然，如果文档已存在，那就相当于数据库的UPDATE。</li>
</ul>
<h3 id="类型（type）"><a href="#类型（type）" class="headerlink" title="类型（type）"></a>类型（type）</h3><p>就目前7.X版本的ES来说，再谈类型（type）的概念已经不是太有意义，因为类型的概念正在被逐渐淡化抛弃。</p>
<p>在5.X或者更早的版本中，类型的概念确实很常用，类型是索引内部的逻辑分区(category/partition)，然而其意义完全取决于用户需求。因此，一个索引内部可定义一个或多个类型(type)。一般来说，类型就是为那些拥有相同的域的文档做的预定义。例如，在一个博客系统类的索引中，可以定义一个用于存储作者信息的类型，一个存储博客文章信息的类型，以及一个存储评论数据的类型。类比传统的关系型数据库领域来说，类型相当于“表”。</p>
<p>然而，从6.X开始单个索引中只能有一个类型，7.X的版本中只存在一个默认的名为“_doc”的类型，官方也不建议继续使用这一概念，甚至8.X以后完全不支持。这是为什么呢？</p>
<p>许多资料指出ES中“索引”的概念和关系数据库的“库”是相似的，“类型”和“表”是对等的。 这其实是一个不正确的对比，掩盖了一些基础的特性。在关系型数据库里,”表”是相互独立的,一个“表”里的列和另外一个“表”的同名列没有关系，互不影响。但在类型里字段不是这样的。在一个ES索引里，所有不同类型的同名字段内部使用的是同一个lucene字段存储。也就是说，上面例子中，作者信息类型的author_name字段和博客文章信息类型的author_name字段是存储在一个字段里的，两个类型里的这一字段必须有一样的字段定义。这可能导致一些问题，例如我们希望在类型1中的phone_number存储为数值类型，而在类型2中的phone_number字段存储为字符类型，这是不可能做到的。另外，在同一个索引中，存储仅有小部分字段相同或者全部字段都不相同的文档，会导致数据稀疏，影响Lucene有效压缩数据的能力。</p>
<p>所以，在一个索引中，最好只拥有一个类型，如果有多种实体数据，那就分别存储在多个索引中。</p>
<h3 id="文档（document）"><a href="#文档（document）" class="headerlink" title="文档（document）"></a>文档（document）</h3><p>在索引中存储的每一个目标数据称为文档，ES中的文档可以类比关系型数据库中的每一行记录来理解。ES是面向文档的搜索，文档是ES所有可搜索数据的最小单元。在ES中文档会被序列化成json格式进行保存，每个文档都会有一个Unique ID，这个ID可以有用户在创建文档的时候指定，在用户未指定时则由ES自己生成，这个ID中在查询结果中以_id这个元数据表示。除了_id外，文档中还包括一下这些元数据：</p>
<ul>
<li>_index：文档所属索引名称。</li>
<li>_type：文档所属类型名。</li>
<li>_id：文档的ID值。</li>
<li>_version：文档的版本信息。ES通过使用version来保证对文档的变更能以正确的顺序执行，避免乱序造成的数据丢失。</li>
<li>_seq_no：严格递增的顺序号，每个文档一个，Shard级别严格递增，保证后写入的Doc的_seq_no大于先写入的Doc的_seq_no。</li>
<li>primary_term：primary_term也和_seq_no一样是一个整数，每当Primary Shard发生重新分配时，比如重启，Primary选举等，_primary_term会递增1</li>
<li>found：查询的ID正确那么ture, 如果 Id 不正确，就查不到数据，found字段就是false。</li>
<li>_source：文档的原始JSON数据，这才是我们储存在ES中的业务数据。</li>
</ul>
<h3 id="映射（mapping）"><a href="#映射（mapping）" class="headerlink" title="映射（mapping）"></a>映射（mapping）</h3><p>ES中中的映射（Mapping）用来定义一个文档，类似于关系型数据库中的表结构的概念，但却比表结构具有更加强大的功能，如下图所示，具体来说主要包含以下功能：</p>
<ul>
<li>文档中哪些字段需要定义成全文索引字段。</li>
<li>文档中哪些字段定义为精确值，例如日期，数字、地理位置等。</li>
<li>文档中哪些字段需要被索引（能通过该字段的值查询文档）。</li>
<li>日期值的格式。</li>
<li>动态添加字段的规则定义等。</li>
</ul>
<p>映射可以分为动态映射和静态映射：</p>
<p>静态映射：若在数据写入索引前，映射（mapping）已经创建，那么在写入数据时，ES会根据映射和写入数据的key进行对比，然后写入相应的映射中；</p>
<p>动态映射：如果mapping没有创建，elasticsearch将会根据写入的数据的key自行创建相应的mapping，并写入数据。</p>
<h3 id="集群（cluster）"><a href="#集群（cluster）" class="headerlink" title="集群（cluster）"></a>集群（cluster）</h3><p>集群是一个或多个节点(服务器)的集合，它们共同保存你的整个数据，并提供跨所有节点的联合索引和搜索功能。一个集群由一个唯一的名称标识，默认这个唯一标识的名称是”elasticsearch”（可修改）。这个名称很重要，因为如果节点被设置为按其名称加入集群，那么节点只能是集群的一部分。</p>
<p>注意，在同一环境中用最好使用不同的集群名称，否则可能导致节点加入到错误的集群中。例如，你可以使用”logging-dev”, “logging-test”, “logging-prod”分别用于开发、测试和正式集群的名字。</p>
<p>ES集群实际上是一个分布式系统，这是ES的一大优势，它需要具备两个特性：</p>
<p>　　1）高可用性</p>
<p>　　　　a）服务可用性：允许有节点停止服务；</p>
<p>　　　　b）数据可用性：部分节点丢失，不会丢失数据；</p>
<p>　　2）可扩展性</p>
<p>　　　　随着请求量的不断提升，数据量的不断增长，系统可以将数据分布到其他节点，实现水平扩展；</p>
<p>ES集群有三种健康状态：</p>
<ul>
<li>green：所有主要分片和复制分片都可用</li>
<li>yellow：所有主要分片可用，但不是所有复制分片都可用</li>
<li>red：不是所有的主要分片都可用</li>
</ul>
<p>我们可以通过查询语句对健康状态进行查询，关注和提升ES集群的健康状态对保证数据安全性、高效查询十分有必要。</p>
<h3 id="节点（node）"><a href="#节点（node）" class="headerlink" title="节点（node）"></a>节点（node）</h3><p>节点是一个ElasticSearch的实例，其本质就是一个Java进程，负责进行数据存储，并且参与集群的索引和搜索功能；一台机器上可以运行多个ElasticSearch实例，但是建议在生产环境中一台机器上只运行一个ElasticSearch实例。</p>
<p>与集群一样，节点由一个名称标识，默认情况下，该名称是在启动时分配给节点的随机通用唯一标识符（UUID）。如果不希望使用默认值，则可以定义所需的任何节点名称。</p>
<p>一个集群可以有任意数量的节点。此外，如果在网络上当前没有运行任何节点，那么此时启动一个节点将默认形成一个单节点的名字叫”elasticsearch”的集群。一个节点可以通过配置集群名称来加入到一个特定的集群中。默认情况下，每个节点都被设置加入到一个名字叫”elasticsearch”的集群中，这就意味着如果你启动了很多个节点，并且假设它们彼此可以互相发现，那么它们将自动形成并加入到一个名为”elasticsearch”的集群中。</p>
<p>在一个ES的集群中包含着多个ES的节点，往往每个节点所扮演的角色也不尽相同，ES的节点类型主要包含以下几类：</p>
<ul>
<li>Master-eligible Node：每个节点启动后，默认是一个 Master-eligible 节点，Master-eligible的节点可参加选主流程，成为Master节点，通过配置项 node.master:falase 可以禁用节点的Master-eligible职责，禁止后当前节点就不会参加选主流程；</li>
<li>Master Node：ES集群中虽然每个节点都保存了集群状态，但是只有Master节点才有修改集群状态的权限，集群状态包括：集群中节点信息、所有索引和其相关的Mapping和Setting信息、分片的路由信息。在集群启动时，第一个启动的Master-eligible节点会将自己选举为主节点；</li>
<li>Data Node：保存数据的节点，负责保存分片数据，对数据扩展有重要作用；</li>
<li>Coordinating Node：负责接受Client请求，将请求分发到合适的节点获取响应后，将结果最终汇集在一起，每个节点默认都有Coordinating节点的职责；</li>
<li>Machine Learning Node：负责运行机器学习的Job，用来做异常检测；</li>
<li>Ingest Node：数据预处理的节点，支持Pipeline管道设置，可以使用Ingest对数据进行过滤、转换等操作。</li>
</ul>
<p>注意，每个ES节点可以承担多个职责。</p>
<h3 id="分片（shard）"><a href="#分片（shard）" class="headerlink" title="分片（shard）"></a>分片（shard）</h3><p>ES的shard（分片）机制可将一个索引内部的数据分布地存储于多个节点，它通过将一个索引切分为多个底层物理的Lucene索引完成索引数据的分割存储功能，这每一个物理的Lucene索引称为一个分片(shard)。每个分片其内部都是一个全功能且独立的索引，因此可由集群中的任何主机存储。创建索引时，用户可指定其分片的数量，默认数量为5个。</p>
<p>Shard有两种类型：primary和replica，即主分片及副本分片。主分片用于文档存储，每个新的索引会自动创建5个主分片，当然此数量可在索引创建之前通过配置自行定义，不过，一旦创建完成，其主分片的数量将不可更改。Replica分片是主分片的副本，用于冗余数据及提高搜索性能，为保证副本分片的有效性，主分片绝不会被创建在同一节点上。每个主分片默认配置了一个副本，但也可以配置多个，且其数量可动态更改。ES会根据需要自动增加或减少这些Replica shard的数量。</p>
<p>ES集群可由多个节点组成，各分片分布式地存储于这些节点上。ES可自动在节点间按需要移动分片，例如增加节点或节点故障时。简而言之，分片实现了集群的分布式存储，而副本实现了其分布式处理及冗余功能。</p>
<h2 id="IK分词器"><a href="#IK分词器" class="headerlink" title="IK分词器"></a>IK分词器</h2><h3 id="安装-1"><a href="#安装-1" class="headerlink" title="安装"></a>安装</h3><p><strong>直接将下载完的文件解压到plugins中，建个文件夹名字ik，把解压完的文件放进去</strong></p>
<p><img src="https://s3.jpg.cm/2020/12/17/kP9lT.png" alt="kP9lT.png"></p>
<h3 id="使用kibana测试"><a href="#使用kibana测试" class="headerlink" title="使用kibana测试"></a>使用kibana测试</h3><p>其中ik_smart为最少切分</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kPTEE.png" alt="kPTEE.png"></p>
<p>il_max_word为最细粒度划分！</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kPajQ.png" alt="kPajQ.png"></p>
<ul>
<li><p><strong>发现问题，自己需要的词被拆分开了怎么办？</strong></p>
<ul>
<li><p>这种自己需要的词，需要我们自己加载到我们的分词器的字典中</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kPZI2.png" alt="kPZI2.png"></p>
</li>
</ul>
</li>
</ul>
<h2 id="Rest风格说明"><a href="#Rest风格说明" class="headerlink" title="Rest风格说明"></a>Rest风格说明</h2><p>一种软件架构风格，而不是标准，知识提供了一组设计原则的约束条件。他主要用于客户端和服务器交互类的软件。基于这个风格设计的软件可以更简洁，更有层次，更易于实现缓存等机制。</p>
<table>
<thead>
<tr>
<th>method</th>
<th>url地址</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>PUT</td>
<td>localhost:9200/索引名称/类型名称/文档id</td>
<td>创建文档（指定文档id）</td>
</tr>
<tr>
<td>POST</td>
<td>localhost:9200/索引名称/类型名称</td>
<td>创建文档（随机文档id）</td>
</tr>
<tr>
<td>POST</td>
<td>localhost:9200/索引名称/类型名称/文档id/_ipdate</td>
<td>修改文档</td>
</tr>
<tr>
<td>DELETE</td>
<td>localhost:9200/索引名称/类型名称/文档id</td>
<td>删除文档</td>
</tr>
<tr>
<td>GET</td>
<td>localhost:9200/索引名称/类型名称/文档id</td>
<td>查询文档通过文档id</td>
</tr>
<tr>
<td>POST</td>
<td>localhost:9200/索引名称/类型名称/_search</td>
<td>查询所有数据</td>
</tr>
</tbody></table>
<h3 id="基础测试"><a href="#基础测试" class="headerlink" title="基础测试"></a>基础测试</h3><ol>
<li><p>创建一个索引</p>
<pre><code>PUT /索引名/类型名（未来就不写了）/文档id
&amp;#123;请求体&amp;#125;</code></pre>
<p><img src="https://s3.jpg.cm/2020/12/17/kRlUy.png" alt="kRlUy.png"></p>
</li>
<li><p>字段类型</p>
<ul>
<li>字符串类型：text、keyword</li>
<li>数值类型：long、integer、short、byte、double、float、scaled、float</li>
<li>日期类型：date</li>
<li>布尔值类型：boolean</li>
<li>二进制类型：binary</li>
</ul>
</li>
<li><p>指定字段类型</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kR6or.png" alt="kR6or.png"></p>
</li>
</ol>
<h2 id="关于文档的基本操作（重点）"><a href="#关于文档的基本操作（重点）" class="headerlink" title="关于文档的基本操作（重点）"></a>关于文档的基本操作（重点）</h2><h3 id="简单操作"><a href="#简单操作" class="headerlink" title="简单操作"></a>简单操作</h3><ol>
<li><p>添加数据</p>
<pre><code>PUT /wang/usr/3
&amp;#123;
  "name": "李四",
  "age": 30,
  "desc": "一顿操作猛如虎",
  "tags": ["靓女","渣男","旅游"]
&amp;#125;</code></pre>
<p><img src="https://s3.jpg.cm/2020/12/17/kR12G.png" alt="kR12G.png"></p>
</li>
<li><p>获取数据 GET</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kRtbX.png" alt="kRtbX.png"></p>
</li>
<li><p>更新数据 POST _update，推荐使用这种更新方式</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kRSDp.png" alt="kRSDp.png"></p>
</li>
<li><p>搜索</p>
<p><img src="https://s3.jpg.cm/2020/12/17/kRsFT.png" alt="kRsFT.png"></p>
</li>
</ol>
<h3 id="复杂操作"><a href="#复杂操作" class="headerlink" title="复杂操作"></a>复杂操作</h3><p>   <strong>查询的参数使用json</strong><img src="https://s3.jpg.cm/2020/12/17/kRk7Q.png" alt="kRk7Q.png"></p>
<pre class=" language-json"><code class="language-json">#输出结果不想要那么多<span class="token punctuation">,</span>例如只想要name和desc两个字段
GET /wang/usr/_search
&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
    <span class="token property">"query"</span><span class="token operator">:</span> &amp;#<span class="token number">123</span><span class="token punctuation">;</span>
        <span class="token property">"mathc"</span> <span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
            <span class="token property">"name"</span> <span class="token operator">:</span><span class="token string">"鸟"</span>
        &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
    &amp;#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span>
    <span class="token property">"_source"</span> <span class="token operator">:</span><span class="token punctuation">[</span><span class="token string">"name"</span><span class="token punctuation">,</span><span class="token string">"desc"</span><span class="token punctuation">]</span>
&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<pre class=" language-json"><code class="language-json">#排序，通过age字段进行排序
GET /wang/usr/_search
&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
    <span class="token property">"query"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
        <span class="token property">"mathc"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
            <span class="token property">"name"</span> <span class="token operator">:</span><span class="token string">"鸟"</span>
        &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
    &amp;#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span>
    <span class="token property">"_source"</span> <span class="token operator">:</span><span class="token punctuation">[</span><span class="token string">"name"</span><span class="token punctuation">,</span><span class="token string">"desc"</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">"sort"</span><span class="token operator">:</span><span class="token punctuation">[</span>
        &amp;#<span class="token number">123</span><span class="token punctuation">;</span>
            <span class="token property">"age"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                <span class="token property">"order"</span><span class="token operator">:</span><span class="token string">"desc"</span>
            &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
        &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
    <span class="token punctuation">]</span>
&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<pre class=" language-json"><code class="language-json">#分页
GET /wang/usr/_search
&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
    <span class="token property">"query"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
        <span class="token property">"mathc"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
            <span class="token property">"name"</span> <span class="token operator">:</span><span class="token string">"鸟"</span>
        &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
    &amp;#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span>
    <span class="token property">"_source"</span> <span class="token operator">:</span><span class="token punctuation">[</span><span class="token string">"name"</span><span class="token punctuation">,</span><span class="token string">"desc"</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">"sort"</span><span class="token operator">:</span><span class="token punctuation">[</span>
        &amp;#<span class="token number">123</span><span class="token punctuation">;</span>
            <span class="token property">"age"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                <span class="token property">"order"</span><span class="token operator">:</span><span class="token string">"desc"</span>
            &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
        &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
    <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token property">"from"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>   #表示从第几行开始
    <span class="token property">"size"</span><span class="token operator">:</span> <span class="token number">20</span>   #表示查询多少条数据
&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<pre class=" language-json"><code class="language-json">#bool查询的使用

#must（and），所有条件都要符合
#should（or），符合其中一个条件即可
#must_not，   不满足
GET /wang/usr/_search
&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
    <span class="token property">"query"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
        bool<span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
            <span class="token property">"must"</span><span class="token operator">:</span><span class="token punctuation">[</span>
                &amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                     <span class="token property">"mathc"</span> <span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                         <span class="token property">"name"</span> <span class="token operator">:</span><span class="token string">"鸟"</span>
                     &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
                &amp;#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span>
                &amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                    <span class="token property">"mathc"</span> <span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                         <span class="token property">"age"</span> <span class="token operator">:</span><span class="token number">23</span>
                     &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
                &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
            <span class="token punctuation">]</span>
        &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
    &amp;#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span>
&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<pre class=" language-json"><code class="language-json">#过滤，过滤出来年龄大于等与<span class="token number">10</span>小于等与<span class="token number">20</span>
#gt   大于
#gte  大于等与
#lt   小于
#lte  小于等与
GET /wang/usr/_search
&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
  <span class="token property">"query"</span><span class="token operator">:</span> &amp;#<span class="token number">123</span><span class="token punctuation">;</span>
      <span class="token property">"bool"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
          <span class="token property">"must_not"</span><span class="token operator">:</span><span class="token punctuation">[</span>
              &amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                  <span class="token property">"match"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                  <span class="token property">"age"</span><span class="token operator">:</span> <span class="token number">23</span>
              &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
              &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
          <span class="token punctuation">]</span><span class="token punctuation">,</span>
          <span class="token property">"filter"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
              <span class="token property">"range"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span> #范围
                  <span class="token property">"age"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
                      <span class="token property">"gte"</span><span class="token operator">:</span> <span class="token number">10</span><span class="token punctuation">,</span>
                      <span class="token property">"lte"</span><span class="token operator">:</span> <span class="token number">20</span>
                  &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
              &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
          &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
      &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
  &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<pre class=" language-json"><code class="language-json"># 如果一个条件多个值，可以直接空格
GET /wang/usr/_search
&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
    <span class="token property">"query"</span><span class="token operator">:</span> &amp;#<span class="token number">123</span><span class="token punctuation">;</span>
        <span class="token property">"mathc"</span> <span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span>
            <span class="token property">"tags"</span> <span class="token operator">:</span><span class="token string">"直男 旅游"</span>
        &amp;#<span class="token number">125</span><span class="token punctuation">;</span>
    &amp;#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span>
&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<p><strong>关于分词</strong></p>
<ul>
<li>term，直接查询精确的</li>
<li>match，会使用分词器解析！（先分析文档，然后通过分析的文档进行查询！）</li>
</ul>
<p><strong>两个类型 text和keyword</strong></p>
<ul>
<li>会被拆分</li>
<li>不会被拆分</li>
</ul>
<script>
        document.querySelectorAll('.github-emoji')
          .forEach(el => {
            if (!el.dataset.src) { return; }
            const img = document.createElement('img');
            img.style = 'display:none !important;';
            img.src = el.dataset.src;
            img.addEventListener('error', () => {
              img.remove();
              el.style.color = 'inherit';
              el.style.backgroundImage = 'none';
              el.style.background = 'none';
            });
            img.addEventListener('load', () => {
              img.remove();
            });
            document.body.appendChild(img);
          });
      </script>
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://gitee.com/yueyueniao-gif/yueyueniao-gif.git" rel="external nofollow noreferrer">Wang Yue Niao</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://gitee.com/yueyueniao-gif/yueyueniao-gif.git/yueyueniao-gif/2020/12/16/elasticsearch/">https://gitee.com/yueyueniao-gif/yueyueniao-gif.git/yueyueniao-gif/2020/12/16/elasticsearch/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="https://gitee.com/yueyueniao-gif/yueyueniao-gif.git" target="_blank">Wang Yue Niao</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/yueyueniao-gif/tags/ElasticSearch/">
                                    <span class="chip bg-color">ElasticSearch</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/yueyueniao-gif/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/yueyueniao-gif/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/yueyueniao-gif/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/yueyueniao-gif/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="far fa-dot-circle"></i>&nbsp;本篇
            </div>
            <div class="card">
                <a href="/yueyueniao-gif/2020/12/16/elasticsearch/">
                    <div class="card-image">
                        
                        
                        <img src="/yueyueniao-gif/medias/featureimages/3.jpg" class="responsive-img" alt="ElasticSearch">
                        
                        <span class="card-title">ElasticSearch</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            ElasticSearch概述
Elaticsearch，简称为es，es是一个开源的高扩展的分布式全文检索引擎，
它可以近乎实时的存储、检索数据；本身扩展性很好，可以扩展到上百台服务器，处理PB级别（大数据时代）的数据。
es也是使用Ja
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-12-16
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/yueyueniao-gif/categories/ElasticSearch/" class="post-category">
                                    ElasticSearch
                                </a>
                            
                            
                        </span>
                    </div>
                </div>

                
                <div class="card-action article-tags">
                    
                    <a href="/yueyueniao-gif/tags/ElasticSearch/">
                        <span class="chip bg-color">ElasticSearch</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/yueyueniao-gif/2020/12/16/dubbo/">
                    <div class="card-image">
                        
                        
                        <img src="/yueyueniao-gif/medias/featureimages/6.jpg" class="responsive-img" alt="Dubbo">
                        
                        <span class="card-title">Dubbo</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            DubboDubbo核心概念Dubbo官网: http://dubbo.apache.org/en-us/index.html
Dubbo 是一款高性能、轻量级的开源Java RPC框架，它提供了三大核心能力：面向接口的远程方法调用，智能容
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-12-16
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/yueyueniao-gif/categories/Dubbo/" class="post-category">
                                    Dubbo
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/yueyueniao-gif/tags/Dubbo/">
                        <span class="chip bg-color">Dubbo</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/yueyueniao-gif/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/yueyueniao-gif/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/yueyueniao-gif/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/yueyueniao-gif/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/yueyueniao-gif/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>


<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default"></script>

    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/yueyueniao-gif/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="2566555574"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/yueyueniao-gif/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
       <h2>没有任何动物比蚂蚁更勤奋，然而它却最沉默寡言</h2><br><br>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/yueyueniao-gif/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/yueyueniao-gif/search.xml", 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/yueyueniao-gif/libs/materialize/materialize.min.js"></script>
    <script src="/yueyueniao-gif/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/yueyueniao-gif/libs/aos/aos.js"></script>
    <script src="/yueyueniao-gif/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/yueyueniao-gif/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/yueyueniao-gif/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/yueyueniao-gif/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/yueyueniao-gif/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    

    
    <script src="/yueyueniao-gif/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
